<template>
	<view>
		<view class="cflex-c-c" style="margin-top: 280rpx;">
			<image style="width: 200rpx;height: 200rpx;" src="../static/logo.png" mode="aspectFill"></image>
			<view class="u-m-t-30 u-font-15">百吉星社工</view>
			<button open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber" shape="circle" hover-class="none" style="margin-top: 40rpx;background-color: #4578F7;border: none;font-size: 30rpx;width: 400rpx;">手机号授权登录</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		onShow() {
			
		},
		onLoad() {
			
		},
		methods: {
			// 获取手机号
			decryptPhoneNumber (e) {
				this.bindPhoneRequest(e);
			},
			bindPhoneRequest(e){
				let that = this 
				uni.login({
					provider: 'weixin',
					success: res => {
						if (res.errMsg == "login:ok") {
							that.jsCode = res.code;
						}else {
							uni.showModal({
								title: '登录失败',
								content: '系统异常，请联系管理员'
							});
						}
					}
				})
				setTimeout(()=>{
					if(e.detail.errMsg=="getPhoneNumber:ok"){
						that.$request("kehu/user/bindWxmallPhone",{data:e.detail.encryptedData,iv:e.detail.iv,jsCode:that.jsCode}).then(res1=>{
							that.$store.commit('setToken',res1.msg);
							uni.reLaunch({
								url:'./tab1'
							})
						})
					}
				},500)
			},
		}
	}
</script>

<style>
	
</style>
